package wwl.lsf;

/**
 * @Title
 * @Author wangwenliang
 * @Date 2021/5/26
 * @Description
 */
public class 跳跃游戏 {

    public static void main(String[] args) {

        int test[] = {0};

        boolean jump = jump(test);
        System.out.println("jump = " + jump);

    }

    public static boolean jump(int[] nums) {

        int length = nums.length;
        int maxJump = 0;

        for (int i = 0; i < length; i++) {
            if (i <= maxJump) {
                maxJump = Math.max(maxJump, i + nums[i]);
                if (maxJump >= length - 1) {
                    return true;
                }
            }
        }

        return false;

    }
}
